#include "SimpleSelectionStrategy.h"

SimpleSelectionStrategy::SimpleSelectionStrategy() : SelectionStrategy(),
                    reproductionIndex(0),
                    toggle(0)
{
}

Chromosome* SimpleSelectionStrategy::selectOne(const QList<Chromosome*>& chromosomeList)
{
    TRACE_FUNC_ENTRY
    Chromosome* chromosome;

    if(reproductionIndex >= chromosomeList.size())
        reproductionIndex = 0;

    //qDebug() << "reproductionIndex" << reproductionIndex;
    chromosome = chromosomeList.value(reproductionIndex);

    reproductionIndex += toggle;
    toggle = !toggle;

    TRACE_FUNC_EXIT
    return chromosome;
}

void SimpleSelectionStrategy::resetTempData()
{
    reproductionIndex = 0;
    toggle = 0;
}
